# !/usr/bin/python3
# -*- coding: utf-8 -*-
# ------------------------------------------
# @Time    : Date - 2021/9/11   Time - 16:02
# @Author  : Spence Guo Tang
# @FileName: meituan_bishi_T1.py
# ------------------------------------------

import sys


def func(num):
    result = 0
    for i in range(len(num)-1):
        if num[i] == "0":
            continue
        for j in range(i+2, len(num)+1):
            if int(num[j-1]) % 2 == 1:
                continue
            if int(num[i:j]) % 22 == 0:
                result += 1
    return result


def func1(num):
    result = 0
    for i in range(len(num)):
        if (ord(num[i]) - ord("0")) % 22 == 0:
            result += 1
    for j in range(1, len(num)):
        if (ord(num[j]) - ord("0") + (ord(num[j-1]) - ord("0")) * 2) % 22 == 0:
            result += j
    return result


def func2(num):
    result = 0
    dp = [0] * 100000000
    temp = 0
    dp[temp] = 0
    t = 1
    for i in range(len(num)-1, -1, -1):
        dp[temp] += 1
        temp = (temp + (ord(num[i]) - ord("0")) * t) % 22
        result += dp[temp]
        t = t * 10 % 22
    return result


if __name__ == '__main__':
    input = sys.stdin.readline().strip()
    print(func(input))
    # print("b"-"a")
